/*
 *  FILE: 
 *  	escape.h
 *
 *  DESCRIPTION:
 *  	Functions used to encode/decode %2F style requests, along with a function
 *      to encode a string into &#47; HTML encoded style.
 *
 *  FUNCTIONS:
 *  	hextochar()     -  Pass two hex values, both below or equal to "F".  Returns char for code.
 *  	html_escape()   -  Escapes plain text into a ``&#47;''style string.  (Escapes reserved HTML characters only.)
 *  	uri_unescape()  -  Unescapes ``%20'' style string into plain text.
 *  	uri_escape()    -  Escapes plain text into a ``%20'' style string. (Escapes reserved URL characters only.)
 *
 *
 * Copyright (c) 2004-2006 Karlan Thomas Mitchell<karlanmitchell@gmail.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *         This product includes software developed by
           Karlan Thomas Mitchell<karlanmitchell@gmail.com>
 * 4. Neither Karlan Thomas Mitchell nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY KARLAN THOMAS MITCHELL AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
#ifndef _URI_ESCAPE_H
#define _URI_ESCAPE_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef PATH_MAX
#define PATH_MAX 255
#endif


#ifndef HAVE___B64_NTOP
# ifndef HAVE_B64_NTOP
int b64_ntop(u_char const *src, size_t srclength, char *target, 
    size_t targsize);
int b64_pton(char const *src, u_char *target, size_t targsize);
# endif /* !HAVE_B64_NTOP */
# define __b64_ntop b64_ntop
# define __b64_pton b64_pton
#endif /* HAVE___B64_NTOP */
 

char msdos_path(char * buffer, char * string, size_t buflen);
char hextochar(char value1, char value2);


int base32_encode(char * buffer, size_t buffer_len, char * string, size_t string_len);
int base32_decode(char * buffer, size_t buffer_len, char * string, size_t string_len);
int uri_to_base32(char * buffer, size_t buffer_len, char * string, size_t string_len);


int html_escape(char * buffer, char * string, size_t buffer_len);

int uri_unescape(char * buffer, char * string, size_t buffer_len);

size_t uri_escape_count(char * string, size_t str_len);

int uri_escape(char * buffer, char * string, size_t buffer_len);
int uri_escape_base(char * buffer, size_t buffer_len, char * string, size_t string_len);
#endif 
